<?php

class Model_news extends CI_Model{
	function __construct()
	{
        parent::__construct();
	}
	
	function getNews($params=array())
	{
		$this->db->select("*");
		$this->db->from("news");
		$this->db->where("is_published",'Y');
		
		if(isset($params['news_id']) )$this->db->where("news_id",$params['news_id']);
		if(isset($params['order_by']) ){
			$this->db->order_by($params['order_by']);
		}else{
			$this->db->order_by("update_date asc, news_id asc");
		}
		if(isset($params['limit_1'])  && isset($params['limit_2']) ) $this->db->limit($params['limit_1'],$params['limit_2']);
		
		$res = $this->db->get();
		if($res->num_rows() > 0)
			return $res->result_array();
		else
			return array();
	}

}
?>